package com.moli.iov.admin.web.controller;


import com.moli.iov.admin.model.vo.req.BaseVo;
import com.moli.iov.admin.model.vo.req.VehicleStatiscalReqVo;
import com.moli.iov.admin.model.vo.req.VehicleStatiscalUpReqVo;
import com.moli.iov.admin.model.vo.res.*;
import com.moli.iov.admin.utils.Contant;

import com.moli.iov.his.model.dto.StatOnlineReportDTO;
import com.moli.iov.his.model.dto.StatOnlineReqDTO;
import com.moli.iov.his.model.po.ReportTotalOnline;
import com.moli.iov.his.remote.IHisStatRemoteService;
import com.moli.iov.his.service.IReportTotalOnlineService;
import com.moli.iov.rest.RestResponse;
import com.moli.iov.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.util.*;

/**
 * @author fudh
 * @ClassNmme HisReportController
 * @date 2018/12/21 14:02
 * @Description: 历史统计前端接口
 */

@Slf4j
@RestController
public class HisReportController extends BaseController{

    @Reference(group = "${service.group}", check = false)
    private IHisStatRemoteService hisStatRemoteService;

    @GetMapping("/index/getOnlineVehiclesTrend")
    public RestResponse getOnlineVehiclesTrend(@RequestBody StatOnlineReqDTO dto) {
        BaseVo baseVo = getBaseVo();

        try{
            if(baseVo!=null && baseVo.getSysCompanyId()!=null){
                dto.setCompanyId(baseVo.getSysCompanyId());
            }

            RestResponse<StatOnlineReportDTO> res = hisStatRemoteService.getStatOnline(dto);
            return res;
        }catch (Exception e){
            return RestResponse.failure("接口查询你异常");
        }
    }

    public static void main(String[] args) {
        Date date = new Date();//获取当前时间    
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.HOUR_OF_DAY,0);
        calendar.set(Calendar.MINUTE,0);
        calendar.set(Calendar.SECOND,0);
        calendar.add(Calendar.DATE, -15);//当前时间减去一年，即一年前的时间    
        System.out.println(DateUtil.format(DateUtil.YEAR_SECOND,calendar.getTime()));;
    }

    //填充日期
}
